package com.car.car.service;

import com.car.car.domian.User;
import com.car.car.enums.ResultEnums;
import com.car.car.exception.UserException;
import com.car.car.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    @Autowired
    private UserRepository userRepository;

    public void getAge(Integer id) throws Exception{
       User user = userRepository.findOne(id);
       Integer age = user.getAge();
       if(age < 10)
       {
            throw new UserException(ResultEnums.TOO_YOUNG);
       }else if (age>10 && age<18){
            throw new UserException(ResultEnums.TOO_SIMPLE);
       }
    }
}
